package com.iamk.finalthesis;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.imageio.ImageIO;

import com.iamk.feature.FColorMSCR;
import com.iamk.feature.ImagesNoRelevance;

public class Test {
	private static HashMap<String, ArrayList<String>> hashMap=new HashMap<>();
	public static HashMap test() {
		File testImages = new File("D:\\University\\Ky10\\datasetImage\\MSRC_ObjCategImageDatabase_v2\\ImageTest_21");
		File[] listFiles = testImages.listFiles();
		
		for(int k=0;k<Constants._KEY;k++){
			hashMap.put(Integer.toString((k+1)), new ArrayList<String>());
//			System.out.println(hashMap.get(Integer.toString(k+1))));
			List list=hashMap.get(Integer.toString(k+1));
//			System.out.println(list.size() +" "+(k+1));
		}
		File images;
		BufferedImage bImage;
		ImagesNoRelevance imagesNoRelevance;
//		String[] labelTruth=LabelGroundTruth.getLabel();
//		StringBuffer buffer=new StringBuffer();
		double temp=0d;
		ArrayList<String> listTemp;
		for (int i = 0; i < listFiles.length; i++) {
			images = new File(listFiles[i].getPath());
			try {
				bImage = ImageIO.read(images);
				FColorMSCR fColor = new FColorMSCR(bImage, "test", "");
				imagesNoRelevance=new ImagesNoRelevance(fColor.extract());
				ArrayList<String> label=imagesNoRelevance.getLabel();
//				System.out.print(images.getName().replace(".bmp", "") +" ");
				for(int j=0;j<label.size();j++){
					listTemp=hashMap.get(label.get(j));
					listTemp.add(listFiles[i].getName().replace(".bmp", ""));
					hashMap.put(label.get(j), (ArrayList<String>)listTemp.clone());
					listTemp.clear();
//					buffer.append(label.get(j));
//					buffer.append(",");
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return hashMap;
	}
	public static void main(String[] args) {
		Test.test();
	}
}
